<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>预约看房</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/public.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/header.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/bottom.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/preset.css">
    <script src="${pageContext.request.contextPath}/renting/js/jQuery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
</head>
<body>
<div class="header">
    <div class="nav">
        <a href="${pageContext.request.contextPath}/renting/index.jsp" class="nav_title">好客租房</a>
        <select class="select">
            <option value="重庆">重庆</option>
            <option value="贵阳">贵阳</option>
            <option value="重庆">重庆</option>
            <option value="贵阳">贵阳</option>
        </select>
        <ul class="nav_ul">
            <li><a href="${pageContext.request.contextPath}/renting/index.jsp">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/Findroom.jsp" style="color: #2983C9;">轻松找房</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/entry.jsp">房东入驻</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/chat_news.jsp">消息</a></li>
            <c:if test="${sessionScope.drom.isHouse==1}">
                <li><a href="${pageContext.request.contextPath}/userInfo/">主页</a></li>
            </c:if>
            <c:if test="${sessionScope.drom.isHouse==0}">
                <li><a href="${pageContext.request.contextPath}/userInfo/">房东</a></li>
            </c:if>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/login.jsp">登录</a></li>
        </ul>
        <img src="${pageContext.request.contextPath}/renting/img/icon/lianxi-1.png" class="nav_img">
        <p class="nav_phone">
            <span>13301131116</span>
            <span>13301131116</span>
        </p>
    </div>
</div>
<div class="preset-content">
    <div class="preset-title">预约看房</div>
    <div class="preset-section">
        <p class="subtitle">房源信息</p>
        <div class="preset-details">
            <div class="details-top">
                <div class="details-pic" id="Lis">

                </div>
                <script>
                    var Listings=$("<img src='${pageContext.request.contextPath}/renting/img/${list.get(6)}'>");
                    Listings.appendTo("#Lis");
                </script>
                <div class="details-right">
                    <p class="details-title">${list.get(0)}</p>
                    <div class="details-subtitle">
                        ${list.get(2)}/${list.get(3)}㎡/${list.get(5)}
                    </div>
                    <div class="details-tag">
                        <span>${list.get(4)}</span>
                        <span>免押金</span>
                        <span>${list.get(7)}</span>
                    </div>
                    <div class="money">
                        <span>${list.get(1)}</span>
                        元/月
                    </div>
                </div>
            </div>
            <div class="details-bottom">
                <p>地址：<span>${list.get(0)} ${list.get(9)}</span></p>
                <!-- 时间插件 -->
                <div class="calendar-con">
                    <span>时间：</span>
                    <input type="text" id="calendar-input" placeholder="请输入日期" />
                    <div class="calendar"></div>
                </div>
                <p>电话：<span>${list.get(8)}</span></p>
            </div>
        </div>
    </div>
    <div class="btn-box">
        <div class="confirm" onclick="buttonClick()">立即预约</div>
    </div>
    <script>

        function buttonClick(){
            if(${drom.isAttest==0}){
                layer.msg("您当前未实名认证",{icon:0,time:500},function () {
                    if(${loginMethod==1}){
                        window.location.href="${pageContext.request.contextPath}/renting/pages/landlord/ID_verification.jsp";
                    }else{
                        window.location.href="${pageContext.request.contextPath}/renting/pages/tenant/ID_verification.jsp";
                    }
                })
                return false;
            }

            var txt = {"userId":${sessionScope.drom1},"houseId":${list.get(11)},"appointment":$("#calendar-input").val(),"reservedCall":${list.get(8)},"status":"未看房"}
            $.ajax({
                url:"${pageContext.request.contextPath}/userInfo/Appoin",// 请求路劲
                type:"post",//提交方式
                data:"text="+JSON.stringify(txt),
                 success:function (data){
                   if (data==1){
                       alert("预约成功！");
                       window.location.href="${pageContext.request.contextPath}/renting/index.jsp"
                   }else {
                       alert("预约失败！")
                   }
                }
            })
        }
    </script>
</div>
<div class="bottom">
    <p>沪公网安备 31011402005354号</p>
</div>
</body>
</html>
<script src="${pageContext.request.contextPath}/renting/js/preset.js" type="text/javascript" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/renting/js/calendar.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/renting/js/header.js"></script>
<script type="text/javascript">
    var login=sessionStorage.getItem("login");
    var url="";
    if(login==1){
        url="${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp";
    }
    if(login==2){
        url="${pageContext.request.contextPath}/renting/pages/landlord/release.jsp";
    }
    judge_login(url,"${pageContext.request.contextPath}/renting/pages/onther/login.jsp");
</script>